<include file="Public/header" />
<title>我的桌面</title>
</head>
<body>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" onclick="delAll()" class="btn btn-danger radius"><i class="Hui-iconfont"></i> 批量删除</a>
            <a class="btn btn-primary radius" data-title="添加角色" _href="article-add.html" onclick="add()" href="javascript:;"><i class="Hui-iconfont"></i> 添加角色</a>
        </span>
    </div>
    <div class="mt-20">
        <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer">
            <table class="table table-border table-bordered table-bg table-hover table-sort dataTable no-footer" id="DataTables_Table_0" role="grid" aria-describedby="DataTables_Table_0_info">
            <thead>
            <tr class="text-c" role="row">
                <th width="25" style="width: 25px;"><input type="checkbox" name="" value=""></th>
                <th width="80" class="" style="width: 80px;">ID</th>
                <th style="width: 487px;">角色名称</th>
                <th width="80" style="width: 80px;">成员数量</th>
                <th width="80" style="width: 80px;">操作人</th>
                <th width="120" style="width: 120px;">添加时间</th>
                <th width="120" style="width: 120px;">操作</th>
            </tr>
            </thead>
            <tbody>
            <foreach name="list" item="data">
            <tr class="text-c odd" role="row">
                <td><input type="checkbox" value="<{$data.id}>" name=""></td>
                <td class="sorting_1"><{$data.id}></td>
                <td class="text-l"><{$data.name}></td>
                <td><{$data.count}></td>
                <td><{$data.operator}></td>
                <td><{$data.created_at}></td>
                <td class="f-14 td-manage">
                    <a style="text-decoration:none" class="ml-5" onclick="edit('<{$data.id}>')" href="javascript:;" title="编辑"><i class="Hui-iconfont"></i></a>
                    <a style="text-decoration:none" class="ml-5" onclick="del('<{$data.id}>')" href="javascript:;" title="删除"><i class="Hui-iconfont"></i></a>
                </td>
            </tr>
            </foreach>
            </tbody>
        </table>
    </div>
</div>
    </div>
<include file="Public/footer" />
<include file="Public/footer_js" />
<script>
    function add(){
        var index=layer.open({
            type: 2,
            title: '角色添加',
            shadeClose: true,
            shade: 0.5,
            area: ['600px', '400px'],
            content: '__MODULE__/Role/department_add' //iframe的url
        });
    }
    function edit(id){
        var index=layer.open({
            type: 2,
            title: '角色修改',
            shadeClose: true,
            shade: 0.5,
            area: ['600px', '400px'],
            content: '__MODULE__/Role/department_edit/id/'+id //iframe的url
        });
    }
    function delAll(){
        var all_ipt=$("#DataTables_Table_0_wrapper input[type=checkbox]:checked");
        var group_id='';
        for(var i=0;i<all_ipt.length;i++){
            if(all_ipt.eq(i).val()!==''){
                group_id+='@'+all_ipt.eq(i).val()
            }
        }
        if(group_id.substring(1)==''){
            layer.msg('请勾选要删除的信息');
            return false;
        }
        del(group_id.substring(1));
    }
    function del(id){
        $.get('__MODULE__/Role/department_del',{
            id:id,
        },function (msg){
            layer.msg(msg.data);
            if(msg.flag==1){
                setTimeout(function (){
                    location.reload();
                },800);
            }
        },'json');
    }
</script>
</body>
</html>